/*
 * Copyright (C) 2009 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.example.android.BluetoothChat.activity;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Window;
import android.widget.TextView;

import com.example.android.BluetoothChat.R;
import com.example.android.BluetoothChat.bean.Player;
import com.example.android.BluetoothChat.constants.IntentConstants;

/**
 * This Activity appears as a dialog. It lists any paired devices and
 * devices detected in the area after discovery. When a device is chosen
 * by the user, the MAC address of the device is sent back to the parent
 * Activity in the result Intent.
 */
public class PlayerDetailsActivity extends Activity {


	@Override
	protected void onCreate(Bundle savedInstanceState) {
		if(PlayerListActivity.D) Log.i(getClass().getSimpleName(), "+++ ON CREATE +++");
		super.onCreate(savedInstanceState);

		// Setup the window
		requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
		setContentView(R.layout.player_details);
		getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title);
		refreshViews();
	}

	@Override
	protected void onDestroy() {
		super.onDestroy();
		if(PlayerListActivity.D) Log.i(getClass().getSimpleName(), "+++ ON DESTROY +++");

	}

	@Override
	protected void onResume() {
		if(PlayerListActivity.D) Log.i(getClass().getSimpleName(), "+++ ON RESUME +++");
		super.onResume();
		refreshViews();
	}

	private void refreshViews() {
		Player locPlayer = (Player) getIntent().getExtras().get(IntentConstants.INTENT_PLAYER);
		TextView locTextView =  (TextView) findViewById(R.id.player_details_name);
		locTextView.setText("Détails du joueur " + locPlayer.getName());
		locTextView = (TextView) findViewById(R.id.player_details_address);
		locTextView.setText("Adress " + locPlayer.getBluetoothMacAddress());
		
	}
}
